﻿// ******************************************************************
// * Copyright(c)  Steven Lu
// * Description   : Entity_PROD_PRODUCT_TECHNIC_ITEM
// * CreateDate    : 2012/2/24 14:41:54
// * Creater       : CodeSmith
// * LastChangeDate: 2012/2/24 14:41:54
// * LastChanger   : 2012/2/24 14:41:54
// * Version Info  : 1.0 For ESOL
// ******************************************************************

using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Suzsoft.Smart.Data;
using ESOL.Common.Entity;

namespace ESOL.Business.Prod
{
    /// <summary>
    /// ProdProductTechnicItem
    /// </summary>
    public partial class ProdProductTechnicItemBs
    {
        #region GetByID
        /// <summary>
        /// Get Entity
        /// </summary>
        /// <param name="objProdProductTechnicItemEntity">Entity</param>
        /// <returns>Entity</returns>
        public static ProdProductTechnicItemEntity GetProdProductTechnicItem(ProdProductTechnicItemEntity objProdProductTechnicItemEntity)
        {
            return DataAccess.SelectSingle<ProdProductTechnicItemEntity>(objProdProductTechnicItemEntity);
        }
        #endregion


        #region Insert
        /// <summary>
        /// Insert Data
        /// </summary>
        /// <param name="objProdProductTechnicItemEntity">Entity</param>
        /// <returns>true Insert Succeed; false Insert Fail</returns>
        public static bool InsertProdProductTechnicItem(ProdProductTechnicItemEntity objProdProductTechnicItemEntity)
        {
            return DataAccess.Insert(objProdProductTechnicItemEntity);
        }

        public static bool InsertProdProductTechnicItem(List<ProdProductTechnicItemEntity> objProdProductTechnicItemEntityList)
        {
            return DataAccess.Insert(objProdProductTechnicItemEntityList);
        }
        #endregion


        #region Update
        /// <summary>
        /// Update Data
        /// </summary>
        /// <param name="objProdProductTechnicItemEntity">Entity</param>
        /// <returns>true Update Succeed; false Update Fail</returns>
        public static bool UpdateProdProductTechnicItem(ProdProductTechnicItemEntity objProdProductTechnicItemEntity)
        {
            return DataAccess.Update(objProdProductTechnicItemEntity);
        }

        public static bool UpdateProdProductTechnicItem(List<ProdProductTechnicItemEntity> objProdProductTechnicItemEntityList)
        {
            return DataAccess.Update<ProdProductTechnicItemEntity>(objProdProductTechnicItemEntityList);
        }
        #endregion


        #region Delete
        /// <summary>
        /// Delete Data
        /// </summary>
        /// <param name="objProdProductTechnicItemEntity">Entity</param>
        /// <returns>true Delete Succeed; false Delete Fail</returns>
        public static bool DeleteProdProductTechnicItem(ProdProductTechnicItemEntity objProdProductTechnicItemEntity)
        {
            return DataAccess.Delete(objProdProductTechnicItemEntity);
        }

        public static bool DeleteProdProductTechnicItem(List<ProdProductTechnicItemEntity> objProdProductTechnicItemEntityList)
        {
            return DataAccess.Delete<ProdProductTechnicItemEntity>(objProdProductTechnicItemEntityList);
        }
        #endregion


        #region GetAll
        /// <summary>
        /// Get All Data
        /// </summary>
        /// <returns>Back All Data<returns>
        public static DataSet GetProdProductTechnicItemAll()
        {
            return DataAccess.SelectAllDataSet<ProdProductTechnicItemEntity>();
        }
        /// <summary>
        /// Get All Data List
        /// </summary>
        /// <returns>Back All Data List<returns>
        public static List<ProdProductTechnicItemEntity> GetProdProductTechnicItemAllList()
        {
            return DataAccess.SelectAll<ProdProductTechnicItemEntity>();
        }
        #endregion

        #region Functions
        public static List<ProdProductTechnicItemEntity> GetListEntityByPlanOrderItemID(string PlanOrderItemID)
        {
            if (string.IsNullOrEmpty(PlanOrderItemID))
                return null;
            string Sql = @"select * from prod_product_technic
                where plan_order_item_id='" + PlanOrderItemID + "'";
            return DataAccess.Select<ProdProductTechnicItemEntity>(Sql);
        }

        public static DataTable GetDtEntityByProductTechnicID(string ProductTechnicID)
        {
            if (string.IsNullOrEmpty(ProductTechnicID))
                return null;
            string Sql = @"select ppti.*,mp.NAME_CN as GROUP_PERSON_NAME from PROD_PRODUCT_TECHNIC_ITEM ppti
                left join MST_PERSON mp on ppti.GROUP_PERSON=mp.PERSON_ID
                where ppti.PRODUCT_TECHNIC_ID='" + ProductTechnicID + "'";
            DataSet Ds = new DataSet();
            Ds=DataAccess.SelectDataSet(Sql);
            if (Ds.Tables[0] != null && Ds.Tables[0].Rows.Count > 0)
                return Ds.Tables[0];
            else return null;
        }
        #endregion
    }


}

